< previous page page_201 next page >

Page 201
The volume serial number is 12EC-0868.
The hint in this case is the appearance of a letter between A and F in the serial number and the fact that the serial number is two four-character numbers. A four-character number in hexadecimal is 16 bits. Two four-character numbers make a 32-bit number.
The difference between the serial number as displayed in the puzzle and that displayed by a DOS window is that one is a decimal number, the other a hexadecimal number.
How do you break up a 32-bit long into two 16-bit hexadecimal numbers?
The high 32 bits can be retrieved by dividing the number by &H10000&. This shifts all of the bits in the number 16 bits to the right. You also need to mask off the high 16 bits of the number using the And operator, because the division operation will not set the high bits to 0 if the highest bit was originally 1. This can be done with the following code:
(SerialNumber \ &H1000) And &HFFFF&
The low 16 bits can be obtained using the And operator and masking with the value &HFFFF&.
The final correct result follows:
' Volume Information
' Copyright © 1998 by Desaware Inc. All Rights Reserved

Option Explicit

Private Declare Function GetVolumeInformation Lib "kernel32" Alias _
"GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal _
lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Long, _
lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, _
lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, _
ByVal nFileSystemNameSize As Long) As Long

Private Sub LoadVolumeInfo()
   Dim res&
   Dim VolumeName As String
   Dim FileSystem As String
   Dim SerialNumber As Long
   Dim ComponentLength As Long
   Dim FileSystemFlags As Long
   VolumeName = String$(256, Chr$(0))
   FileSystem = String$(256, Chr$(0))

 
< previous page page_201 next page >